package depthtag.display;


import java.awt.BorderLayout;
import java.awt.Event;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;

import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.filechooser.FileFilter;

import depthtag.MainClass;
import depthtag.Task;
import depthtag.filter.ExifToolFilter;
import depthtag.filter.RawFileFilter;
import depthtag.filter.ZXUFileFilter;
import javax.swing.JComboBox;



public class Viewer {

	private JFrame jFrame = null;  //  @jve:decl-index=0:visual-constraint="10,10"
	private JPanel jContentPane = null;
	private JMenuBar jJMenuBar = null;
	private JMenu fileMenu = null;
	private JMenu helpMenu = null;
	private JMenuItem exitMenuItem = null;
	private JMenuItem aboutMenuItem = null;
	private JMenuItem saveMenuItem = null;
	private JDialog aboutDialog = null;
	private JPanel aboutContentPane = null;
	private JLabel aboutVersionLabel = null;
	private JPanel exifLocationPanel = null;
	private JLabel jLabel = null;
	private JTextField jTextField = null;
	private JFileChooser jFileChooser = null;  //  @jve:decl-index=0:visual-constraint="866,74"
	private JButton lauchFileChooserButton = null;
	private JLabel jLabel1 = null;
	private JTextField logFolderTextField = null;
	private JButton browseLogfileButton = null;
	private JLabel jLabel2 = null;
	private JTextField pictureFolderTextField = null;
	private JButton pictureFolderBrowser = null; 
	

	private JTextPane statusPane = null;
	private JButton parseLogButton = null;
	private JButton matchPicturesButton = null;
	private MainClass callback;
	private JScrollPane jScrollPane = null;
	private JScrollBar jScrollBar = null;
	private JButton updatePictures = null;
	private JButton testExifToolButton = null;
	private JComboBox fileFormatCombo = null;
	
	private int selectedFileNameExtension;
	private JLabel numberOfLogFilesReadLabel = null;
	private JComboBox metricOrFeetCombo = null;
	/**
	 * This method initializes exifLocationPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getExifLocationPanel() {
		if (exifLocationPanel == null) {
			GridBagConstraints gridBagConstraints24 = new GridBagConstraints();
			gridBagConstraints24.fill = GridBagConstraints.VERTICAL;
			gridBagConstraints24.gridy = 7;
			gridBagConstraints24.weightx = 1.0;
			gridBagConstraints24.gridx = 4;
			GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
			gridBagConstraints12.gridx = 0;
			gridBagConstraints12.gridy = 6;
			numberOfLogFilesReadLabel = new JLabel();
			numberOfLogFilesReadLabel.setText("0 logs");
			GridBagConstraints gridBagConstraints23 = new GridBagConstraints();
			gridBagConstraints23.gridy = 2;
			gridBagConstraints23.gridx = 4;
			GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
			gridBagConstraints21.gridx = 4;
			gridBagConstraints21.gridy = 0;
			GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
			gridBagConstraints11.gridx = 1;
			gridBagConstraints11.gridy = 7;
			GridBagConstraints gridBagConstraints36 = new GridBagConstraints();
			gridBagConstraints36.gridx = 3;
			gridBagConstraints36.gridy = 0;
			GridBagConstraints gridBagConstraints35 = new GridBagConstraints();
			gridBagConstraints35.gridx = 1;
			gridBagConstraints35.gridy = 6;
			GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
			gridBagConstraints7.gridx = 4;
			gridBagConstraints7.gridy = 1;
			GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
			gridBagConstraints6.fill = GridBagConstraints.BOTH;
			gridBagConstraints6.gridy = 2;
			gridBagConstraints6.weightx = 1.0;
			gridBagConstraints6.gridx = 1;
			GridBagConstraints gridBagConstraints22 = new GridBagConstraints();
			gridBagConstraints22.fill = GridBagConstraints.BOTH;
			gridBagConstraints22.gridy = 0;
			gridBagConstraints22.weightx = 1.0;
			gridBagConstraints22.gridx = 1;
			GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
			gridBagConstraints5.fill = GridBagConstraints.BOTH;
			gridBagConstraints5.gridy = 1;
			gridBagConstraints5.weightx = 1.0;
			gridBagConstraints5.gridx = 1;
			GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
			gridBagConstraints4.gridx = 3;
			gridBagConstraints4.gridy = 2;
			GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
			gridBagConstraints3.gridx = 3;
			gridBagConstraints3.gridy = 1;
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
			gridBagConstraints2.gridx = 0;
			gridBagConstraints2.gridy = 2;
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.gridx = 0;
			gridBagConstraints1.gridy = 1;
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.gridy = 0;
			jLabel2 = new JLabel();
			jLabel2.setText("Pictures");
			jLabel1 = new JLabel();
			jLabel1.setText("Logfiles");
			jLabel = new JLabel();
			jLabel.setText("ExifTool");
			exifLocationPanel = new JPanel();
			exifLocationPanel.setLayout(new GridBagLayout());
			exifLocationPanel.add(jLabel, gridBagConstraints);
			exifLocationPanel.add(getExifToolField(),gridBagConstraints22);
			exifLocationPanel.add(getLauchFileChooserButton(), gridBagConstraints36);
			exifLocationPanel.add(jLabel1, gridBagConstraints1);
			exifLocationPanel.add(getLogFolderTextField(), gridBagConstraints5);
			exifLocationPanel.add(getBrowseLogfileButton(), gridBagConstraints3);
			exifLocationPanel.add(jLabel2, gridBagConstraints2);
			exifLocationPanel.add(getPictureFolderTextField(), gridBagConstraints6);
			exifLocationPanel.add(getPictureFolderBrowser(), gridBagConstraints4);
			exifLocationPanel.add(getParselogButton(), gridBagConstraints7);
			exifLocationPanel.add(getMatchPicturesButton(), gridBagConstraints35);
			exifLocationPanel.add(getUpdatePictures(), gridBagConstraints11);
			exifLocationPanel.add(getTestExifToolButton(), gridBagConstraints21);
			exifLocationPanel.add(getFileFormatCombo(), gridBagConstraints23);
			exifLocationPanel.add(numberOfLogFilesReadLabel, gridBagConstraints12);
			exifLocationPanel.add(getMetricOrFeetCombo(), gridBagConstraints24);
		}
		return exifLocationPanel;
	}

	public Viewer(MainClass callback) {
		super();
		this.callback = callback;
		loadSettings();
		getJFrame().setVisible(true);
	}
	public String[] getFileNameExtension() {
		String fileNameExtensions = (String)getFileFormatCombo().getItemAt(selectedFileNameExtension);
		fileNameExtensions = fileNameExtensions.toLowerCase();
		return fileNameExtensions.split(",");
	}
	public void addStatusText(String text){ 
		String returnString = "";
		if(statusPane.getText() != null && statusPane.getText().length() > 0){
			returnString = "\n";
		}
		statusPane.setText(statusPane.getText() + returnString + text);
	}
	
	private boolean isMetric(){
		return "Metric".equals(metricOrFeetCombo.getSelectedItem());
	}
	
	private void saveSettings(){
		Properties props = new Properties();
		props.put("exifLocation", getExifToolField().getText());
		props.put("logfileLocation", getLogFolderTextField().getText());
		props.put("pictureLocation", getPictureFolderTextField().getText());
		props.put("fileNameExtensions", String.valueOf(selectedFileNameExtension));
		props.put("isMetric", String.valueOf(isMetric()));
		try {
			props.store(new FileOutputStream("depthtag.properties"),"");
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	private void loadSettings(){
		//create an instance of properties class

        Properties props = new Properties();

        //try retrieve data from file
           try {
        	   props.load(new FileInputStream("depthtag.properties"));

        	   getExifToolField().setText(props.getProperty("exifLocation"));
        	   getLogFolderTextField().setText(props.getProperty("logfileLocation"));
        	   getPictureFolderTextField().setText(props.getProperty("pictureLocation"));
        	   selectedFileNameExtension = Integer.parseInt( props.getProperty("fileNameExtensions","0"));
        	   boolean isMetric = Boolean.parseBoolean(props.getProperty("isMetric", "true"));
        	   getMetricOrFeetCombo().setSelectedItem((isMetric)?"Metric":"Imperial");
           }

           //catch exception in case properties file does not exist
           catch(IOException e)
           {
        	   try {
				props.store(new FileOutputStream("depthtag.properties"),"");
			} catch (FileNotFoundException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} catch (IOException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			} 
           }
		
	}

	/**
	 * This method initializes jTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getExifToolField() {
		if (jTextField == null) {
			jTextField = new JTextField();
			 new FileDrop( jTextField, /*dragBorder,*/ new FileDrop.Listener()
		        {   public void filesDropped( java.io.File[] files )
		            {   for( int i = 0; i < files.length; i++ )
		                {   try
		                    {   jTextField.setText( files[i].getCanonicalPath()  );
		                    }   // end try
		                    catch( java.io.IOException e ) {}
		                }   // end for: through each dropped file
		            }   // end filesDropped
		        }); // end FileDrop.Listener
		}
		return jTextField;
	}

	/**
	 * This method initializes lauchFileChooserButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getLauchFileChooserButton() {
		if (lauchFileChooserButton == null) {
			lauchFileChooserButton = new JButton();
			lauchFileChooserButton.setText("Browse");
			lauchFileChooserButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					File choosedFile = launchFilechooser("Choose ExifTool", new ExifToolFilter(), JFileChooser.FILES_AND_DIRECTORIES, jTextField.getText());
					if(choosedFile != null){
						jTextField.setText(choosedFile.getAbsolutePath());
					}
				} 
			});
		}
		return lauchFileChooserButton;
	}

	/**
	 * This method initializes logFolderTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getLogFolderTextField() {
		if (logFolderTextField == null) {
			logFolderTextField = new JTextField();
			new FileDrop( logFolderTextField, /*dragBorder,*/ new FileDrop.Listener()
	        {   public void filesDropped( java.io.File[] files )
	            {   
	        		String folder = "";
	        		for( int i = 0; i < files.length; i++ )
	                {   try
	                    {   
	                		File file = files[i];
	                		if(file.isFile()){
	                			folder = file.getParentFile().getCanonicalPath();
	                		}
	                		else{
	                			folder = file.getCanonicalPath();	                			
	                		}
	                    } // end try
	                    catch( java.io.IOException e ) {}
	                }   // end for: through each dropped file
	        		logFolderTextField.setText(folder);
	            }   // end filesDropped
	        }); // end FileDrop.Listener
		}
		return logFolderTextField;
	}

	/**
	 * This method initializes browseLogfileButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getBrowseLogfileButton() {
		if (browseLogfileButton == null) {
			browseLogfileButton = new JButton();
			browseLogfileButton.setText("Browse");
			browseLogfileButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					File choosedFile = launchFilechooser("Choose divelogs", new ZXUFileFilter(), JFileChooser.FILES_AND_DIRECTORIES, logFolderTextField.getText());
					if(choosedFile != null){
						String folder = "";
						if(choosedFile.isDirectory()){
							folder = choosedFile.getAbsolutePath();
						}
						else{
							folder = choosedFile.getParentFile().getAbsolutePath();
						}
						logFolderTextField.setText(folder);
					}
				}
			});
		}
		return browseLogfileButton;
	}

	/**
	 * This method initializes pictureFolderTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getPictureFolderTextField() {
		if (pictureFolderTextField == null) {
			pictureFolderTextField = new JTextField();
			new FileDrop( pictureFolderTextField, /*dragBorder,*/ new FileDrop.Listener()
	        {   public void filesDropped( java.io.File[] files )
	            {   
	        		String folder = "";
	        		for( int i = 0; i < files.length; i++ )
	                {   try
	                    {   
	                		File file = files[i];
	                		if(file.isFile()){
	                			folder = file.getParentFile().getCanonicalPath();
	                		}
	                		else{
	                			folder = file.getCanonicalPath();	                			
	                		}
	                    }   // end try
	                    catch( java.io.IOException e ) {}
	                }   // end for: through each dropped file
	        		pictureFolderTextField.setText(folder);
	            }   // end filesDropped
	        }); // end FileDrop.Listener
		}
		return pictureFolderTextField;
	}

	/**
	 * This method initializes pictureFolderBrowser	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getPictureFolderBrowser() {
		if (pictureFolderBrowser == null) {
			pictureFolderBrowser = new JButton();
			pictureFolderBrowser.setText("Browse");
			pictureFolderBrowser.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					File choosedFile = launchFilechooser("Choose picture folder", new RawFileFilter(), JFileChooser.FILES_AND_DIRECTORIES, pictureFolderTextField.getText());
					
					if(choosedFile != null){
						String folder = "";
						if(choosedFile.isDirectory()){
							folder = choosedFile.getAbsolutePath();
						}
						else{
							folder = choosedFile.getParentFile().getAbsolutePath();
						}
						pictureFolderTextField.setText(folder);
					}
				}
			});
		}
		return pictureFolderBrowser;
	}

	/**
	 * This method initializes statusPane	
	 * 	
	 * @return javax.swing.JTextPane	
	 */
	private JTextPane getStatusPane() {
		if (statusPane == null) {
			statusPane = new JTextPane();
		}
		return statusPane;
	}

	/**
	 * This method initializes jFrame
	 * 
	 * @return javax.swing.JFrame
	 */
	private JFrame getJFrame() {
		if (jFrame == null) {
			jFrame = new JFrame();
			jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			jFrame.setJMenuBar(getJJMenuBar());
			jFrame.setSize(556, 399);
			jFrame.setContentPane(getJContentPane());
			jFrame.setTitle("Application");
			jFrame.addWindowListener(new java.awt.event.WindowAdapter() {
				public void windowClosing(java.awt.event.WindowEvent e) {
					System.out.println("windowClosing()"); // TODO Auto-generated Event stub windowClosing()
					saveSettings();
				}
			});
		}
		return jFrame;
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			GridLayout gridLayout = new GridLayout();
			gridLayout.setRows(2);
			gridLayout.setColumns(3);
			jContentPane = new JPanel();
			jContentPane.setLayout(gridLayout);
			jContentPane.add(getExifLocationPanel(), null);
			jContentPane.add(getJScrollPane(), null);
		} 
		return jContentPane;
	}

	/**
	 * This method initializes jJMenuBar	
	 * 	
	 * @return javax.swing.JMenuBar	
	 */
	private JMenuBar getJJMenuBar() {
		if (jJMenuBar == null) {
			jJMenuBar = new JMenuBar();
			jJMenuBar.add(getFileMenu());
			jJMenuBar.add(getHelpMenu());
		}
		return jJMenuBar;
	}
	
	
	private File launchFilechooser(String dialogTitle, FileFilter fileFilter, int selectionMode, String currentDirectory){
		
		if(jFileChooser == null){
			jFileChooser = new JFileChooser(currentDirectory);
		}
		if(currentDirectory != null && currentDirectory.length() > 0){
			File f = new File(currentDirectory);
			if(f.canRead()){
				jFileChooser.setCurrentDirectory(f);				
			}
		}
		jFileChooser.setDialogTitle (dialogTitle);
		jFileChooser.setFileSelectionMode( selectionMode);
		jFileChooser.setFileFilter(fileFilter);
		// Now open chooser
		int result = jFileChooser.showOpenDialog (jFrame);

		if (result == JFileChooser.CANCEL_OPTION) {
			return null;
		} else if (result == JFileChooser.APPROVE_OPTION) {

			File fFile = jFileChooser.getSelectedFile ();
			return fFile;
		} 
		return null;
	}
	

	/**
	 * This method initializes jMenu	
	 * 	
	 * @return javax.swing.JMenu	
	 */
	private JMenu getFileMenu() {
		if (fileMenu == null) {
			fileMenu = new JMenu();
			fileMenu.setText("File");
			fileMenu.add(getSaveMenuItem());
			fileMenu.add(getExitMenuItem());
		}
		return fileMenu;
	}

	/**
	 * This method initializes jMenu	
	 * 	
	 * @return javax.swing.JMenu	
	 */
	private JMenu getHelpMenu() {
		if (helpMenu == null) {
			helpMenu = new JMenu();
			helpMenu.setText("Help");
			helpMenu.add(getAboutMenuItem());
		}
		return helpMenu;
	}

	/**
	 * This method initializes jMenuItem	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getExitMenuItem() {
		if (exitMenuItem == null) {
			exitMenuItem = new JMenuItem();
			exitMenuItem.setText("Exit");
			exitMenuItem.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					System.exit(0);
				}
			});
		}
		return exitMenuItem;
	}

	/**
	 * This method initializes jMenuItem	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getAboutMenuItem() {
		if (aboutMenuItem == null) {
			aboutMenuItem = new JMenuItem();
			aboutMenuItem.setText("About");
			aboutMenuItem.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					JDialog aboutDialog = getAboutDialog();
					aboutDialog.pack();
					Point loc = getJFrame().getLocation();
					loc.translate(20, 20);
					aboutDialog.setLocation(loc);
					aboutDialog.setVisible(true);
				}
			});
		}
		return aboutMenuItem;
	}

	/**
	 * This method initializes aboutDialog	
	 * 	
	 * @return javax.swing.JDialog
	 */
	private JDialog getAboutDialog() {
		if (aboutDialog == null) {
			aboutDialog = new JDialog(getJFrame(), true);
			aboutDialog.setTitle("About");
			aboutDialog.setContentPane(getAboutContentPane());
		}
		return aboutDialog;
	}

	/**
	 * This method initializes aboutContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getAboutContentPane() {
		if (aboutContentPane == null) {
			aboutContentPane = new JPanel();
			aboutContentPane.setLayout(new BorderLayout());
			aboutContentPane.add(getAboutVersionLabel(), BorderLayout.CENTER);
		}
		return aboutContentPane;
	}

	/**
	 * This method initializes aboutVersionLabel	
	 * 	
	 * @return javax.swing.JLabel	
	 */
	private JLabel getAboutVersionLabel() {
		if (aboutVersionLabel == null) {
			aboutVersionLabel = new JLabel();
			aboutVersionLabel.setText("Made by Björn Bergenheim, with help of Exiftool, Moss, and Robert Harder's FileDrop.  ");
			aboutVersionLabel.setHorizontalAlignment(SwingConstants.CENTER);
		}
		return aboutVersionLabel;
	}

	/**
	 * This method initializes jMenuItem	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getSaveMenuItem() {
		if (saveMenuItem == null) {
			saveMenuItem = new JMenuItem();
			saveMenuItem.setText("Save");
			saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
					Event.CTRL_MASK, true));
		}
		return saveMenuItem;
	}

	/**
	 * This method initializes jButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getParselogButton() {
		if (parseLogButton == null) {
			parseLogButton = new JButton();
			parseLogButton.setText("Parse logs");
			parseLogButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					callback.addTask(new Task(Task.PARSE_LOGS).setLogFolder(getLogFolderTextField().getText()));
				}
			});
		}
		return parseLogButton;
	}

	/**
	 * This method initializes matchPicturesButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getMatchPicturesButton() {
		if (matchPicturesButton == null) {
			matchPicturesButton = new JButton();
			matchPicturesButton.setText("Test matches");
			matchPicturesButton.setToolTipText("Only tests if there are \nmatches, dont edit any files");
			matchPicturesButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					callback.addTask(new Task(Task.MATCH_PICTURES).setPathToExifTool(getExifToolField().getText()).setPictureFolder(getPictureFolderTextField().getText()));
				}
			});
		}
		return matchPicturesButton;
	}

	/**
	 * This method initializes jScrollPane	
	 * 	
	 * @return javax.swing.JScrollPane	
	 */
	private JScrollPane getJScrollPane() {
		if (jScrollPane == null) {
			jScrollPane = new JScrollPane();
			jScrollPane.setVerticalScrollBar(getJScrollBar());
			jScrollPane.setViewportView(getStatusPane());
		}
		return jScrollPane;
	}

	/**
	 * This method initializes jScrollBar	
	 * 	
	 * @return javax.swing.JScrollBar	
	 */
	private JScrollBar getJScrollBar() {
		if (jScrollBar == null) {
			jScrollBar = new JScrollBar();
		}
		return jScrollBar;
	}

	/**
	 * This method initializes updatePictures	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getUpdatePictures() {
		if (updatePictures == null) {
			updatePictures = new JButton();
			updatePictures.setText("Update pictures");
			updatePictures.setToolTipText("Matches and saves the matching files.");
			updatePictures.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					callback.addTask(new Task(Task.UPDATE_PICTURES).setPathToExifTool(getExifToolField().getText()).setPictureFolder(getPictureFolderTextField().getText()));
				}
			});
		}
		return updatePictures;
	}

	/**
	 * This method initializes testExifToolButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	private JButton getTestExifToolButton() {
		if (testExifToolButton == null) {
			testExifToolButton = new JButton();
			testExifToolButton.setText("Test");
			testExifToolButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					callback.addTask(new Task(Task.TEST_EXIF_TOOL).setPathToExifTool(getExifToolField().getText()));
				}
			});
		}
		return testExifToolButton;
	}

	/**
	 * This method initializes fileFormatCombo	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getFileFormatCombo() {
		if (fileFormatCombo == null) {
			fileFormatCombo = new JComboBox(new String[]{"XMP","CR2,CRW","JPG,JPEG"});
			fileFormatCombo.setToolTipText("Select file-type to user");
			fileFormatCombo.setSelectedIndex(selectedFileNameExtension);
			fileFormatCombo.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					selectedFileNameExtension = fileFormatCombo.getSelectedIndex();
				}
			});
		}
		return fileFormatCombo;
	}
	
	public void setNrOfLogs(int nrOfLogs){
		numberOfLogFilesReadLabel.setText(nrOfLogs + " logs");
	}

	/**
	 * This method initializes metricOrFeetCombo	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getMetricOrFeetCombo() {
		if (metricOrFeetCombo == null) {
			metricOrFeetCombo = new JComboBox(new String[]{"Metric","Imperial"});
			metricOrFeetCombo.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					callback.setMetric( isMetric() );
				}
			});
		}
		return metricOrFeetCombo;
	}
	
}
